﻿namespace Deppton.Mobile
{
    using System;
    using System.Windows.Forms;
    using System.Net;

    internal static class Program
    {
        [MTAThread]
        internal static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomainUnhandledException);
            using (var bootstrapController = new BootstrapController())
            {
                Application.Run(bootstrapController.MainForm);
            }

            CloseGps();
        }

        static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            CloseGps();
        }

        private static void CloseGps()
        {
            var gps = new Gps.Gps();

            gps.Open();
            gps.Close();
        }
    }
}